package com.masterclient.app.businessmodule.minemodule.version

import android.annotation.SuppressLint
import android.app.Activity
import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.eoner.common.config.Config
import com.eoner.middlelib.router.map.FCRouterPath
import com.masterclient.app.R
import com.gyf.immersionbar.ImmersionBar
import kotlinx.android.synthetic.main.activity_version.*

/**
 * 作者：sean
 * 创建时间：2018/5/16 14:50
 * 功能说明：
 */
@Route(path = FCRouterPath.MINE_VERSION_PATH)
class VersionActivity : Activity() {

    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_version)
        ImmersionBar.with(this).statusBarDarkFont(true)
                .statusBarView(view_statusbar).transparentStatusBar().init();


        rl_back.setOnClickListener { finish() }

        val cur_version = intent.getStringExtra("version")
        tv_old_version.text = "中华大师汇 v$cur_version"

        val strs = cur_version.split(".")
        val sBuilder = StringBuilder()
        for (s in strs){
            sBuilder.append(s)
        }
        if(sBuilder.toString().toInt()>=Config.NEW_VERSION.toInt()){
            tv_new_version.visibility = View.GONE
        }

        tv_new_version.text = "检测到最新版本V"+getVersion()

    }

    private fun getVersion():String{
        var chars = Config.NEW_VERSION.toCharArray();
        var version:StringBuilder = StringBuilder()
        for (c in chars){
            version.append(c+".")
        }
        return version.substring(0,version.length-1)
    }
}